package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.model.TiXianBean;
import com.qf.flash.mvp.contract.TiXianContract;
import com.qf.flashlib.app.FlashLib;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseResponse;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

public class TiXianPresenter extends BasePresenter<TiXianContract.View> implements TiXianContract.Presenter {
    String id = UserMgr.getInstance().getLoginUser().getUid();
    @Override
    public void getMoney(String type) {

        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .GET_MY_MONEY(id, type)
                .compose(RxUtils.handleBaseResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<BaseResponse<TiXianBean>>(mRootView) {
                    @Override
                    public void onSuccess(BaseResponse<TiXianBean> response) {
                        mRootView.setMyMoney(response.getData());
                    }
                })
        );
    }

    @Override
    public void startTakeMoney(String bankId, String type, double money) {
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .TI_XIAN_MONEY(id, bankId, type, money)
                .compose(RxUtils.handleBaseResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<BaseResponse<Object>>(mRootView) {
                    @Override
                    public void onSuccess(BaseResponse<Object> response) {
                        FlashLib.showToast("申请提现成功");
                    }
                })
        );
    }



}
